<script type="text/javascript"
     src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<head>
    <link rel="stylesheet" href="stylesheet_TMATS.css">
</head>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<title>
    T-MATS: Help for Turbine Library Block
</title>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<body>
    <h1>
      T-MATS: Turbine Library Block
    </h1>
<hr>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="purpose">
        Purpose
</div>

<p>
    This block can be used to simulate the performance of a turbine using basic
    thermodynamic equations, properties, and table lookups.
</p>

<br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="background">
        Background
</div>
<p>
General turbine performance is dictated by a turbine map that relates
    corrected shaft speed and pressure ratio
    to corrected mass flow and efficiency. Values in this map may be scaled
    (for example 100% shaft speed might correlate to 20,000 rpm), so in this discussion all values
    taken from the map will be refered to as Map parameters.
</p>
<h2>
Cooling flows
</h2>
<p>
    To compute the output parameters, this block first checks if the user
    has selected to use the cooling flow. This choice is accessed by double
    clicking the block and navigating to the CoolingFlow tab. If enabled, the
    corresponding variables for the cooling flow are intialized. If not enabled,
    these variables are set to be equal to zero.
</p>
<p>
    It is important to note that if cooling is enabled, the cooling flow input
    vector must have a length of the product of C and 5 in which C is equal to the number of
    positions specified under the CoolingFlow tab. The bleeds for the turbines are considered to
    enter the main gas path either at the front or rear of the turbine. In an actual turbine
    this flow would enter the stream throughout the length of the turbine, through cooling
    holes on the blades and throughout the casing, lining, and/or other portions of the rotor. As such, this
    solution is imperfect, however it has been proven to be adequate when using an appropriate
    input to output flow ratio. In terms of simulation, the cooling flow at the
    inlet produce as it moves through the turbine and, conversely, the
    cooling flow at the exit does not.<br><br>
    The cooling mass flow is
    determined at station one (front of engine) and the exit
    by the following equations:

    $$Wcool_{s1} = \sum Wcool_{in}$$
    $$Wcool_{Out} = \sum Wcool$$

    In these equations, <i>Wcool<sub>s1</sub></i> and <i>Wcool<sub>Out</sub></i>
    are the cooling flow at station 1 of the turbine and the total cooling flow
    at the exit, respectively.
</p>
<p>
    Similarly, the fuel mass flow for the cooling flow is determined by the
    following equations for station one and the exit, respectively.

    $$Wfcool_{s1} = \sum \frac{FARcool_{in}*Wcool_{in}}{1+FARcool_{in}}$$
    $$Wfcool_{Out} = \sum \frac{FARcool*Wcool}{1+FARcool}$$

    Just like before, <i>Wfcool<sub>s1</sub></i> and <i>Wfcool<sub>Out</sub></i>
    are the fuel mass flow at station one and for the total stream at the exit.
</p>
<p>
    The total flow at station one and the exit is determined by the following
    equations:

    $$W_{s1-In} = W_{In} + Wcool_{s1}$$
    $$W_{Out} = W_{In} + Wcool_{out}$$

    The fuel to air ratio at station one and the exit is determined by the
    following equations:

    $$FAR_{s1-In} = \frac{\left(\frac{FAR_{In}* W_{In}}{1+FAR_{In}} + Wfcool_{s1}\right)}{\frac{W_{In}}{1+FAR_{In}} + Wcool_{s1}- Wfcool_{s1}}$$
    $$FAR_{Out} = \frac{\left(\frac{FAR_{In}* W_{In}}{1+FAR_{In}}+ Wfcool_{Out}\right)}{\frac{W_{In}}{1+FAR_{In}} + Wcool_{Out}- Wfcool_{Out}}$$

    The enthalpy of the cooling flow is then determined at station one
    and the exit. The following equations are used to determine the
    cooling flow enthalpy.

    $$dHcool_{s1} = \sum htcool_{in}*Wcool_{in}$$
    $$dHcool_{Out} = \sum htcool_{exit}*Wcool_{exit}$$

    In the above equations, <i>dHcool<sub>s1</sub></i> and <i>dHcool<sub>Out</sub></i>
    are the enthalpy of the cooling flow at station 1 and the exit. Note: unlike the exit
    parameters above, exit enthalpy is not an enthalpy for all cooling flows. It only
    conciders the enthlapy of the cooling flow entering the stream at the exit.
</p>
<p>
    The average enthalpy at station one is then determined by the following
    equations, in which <i>ht<sub>In</sub></i> is determined via table lookup,
     using the input total temperature and fuel to air ratio as the lookup
     parameters.

    $$ht_{s1-In} = \frac{ht_{In}*W_{In} + dHcool_{s1}}{W_{s1-In}}$$

    The total temperature and entropy at station one are then determined
    via table lookup using the other parameters (enthalpy, fuel to air ratio,
    total pressure input, etc.) as the lookup parameters.
</p>
<h2>
Operational Modes
</h2>
<p>
    At this point, it is important to cover the other design options available to
    the user. By double clicking the block and navigating to the iDesign tab,
    the user can adjust what aspects of the design they want to use by inputting
    0, 1, or 2 for the option of <i>iDesign_M</i>.
    <ul>
        <li>If 0 is input, iDesign will be enabled and the turbine map scalars
        will be determined by the design variables in the iDesign tab. The
        scalar constants defined in the T-Map tab will not be used.
        <li>If 1 is input, the turbine map scalars will be determined by values
        in a user-specified file (<i>FVar_M</i>) in the iDesign tab.
        <li>If 2 is input, the turbine map scalars will be determined by the
        values specified in the T-Map tab; no values from the iDesign tab
        will be used.
    </ul>
    For more information on how to enable iDesign and the different options
    for how to use it, see the Mask Variables table at the bottom of this page.
</p>
<h2>
Parameters Correction and Turbine Map Lookup
</h2>
<p>
    Other fluid condition related variables are determined by the following
    equations, in which <i>C_PSTD</i> and <i>C_TSTD</i> are constants for the
    pressure and temperature at standard day conditions.

    $$\delta = \frac{Pt_{In}}{\textit{C_PSTD}}$$
    $$\Theta = \frac{Tt_{In}}{\textit{C_TSTD}}$$

</p>
<p>
    With this description of design options in mind, the corrected speed is
    determined by the following equation:

    $$Nc = \frac{Nmech}{\sqrt{\Theta}}$$

    If iDesign is enabled, the corrected speed scalar constant is determined
    by the following equation. Otherwise, this constant is set equal to the
    user-specified value.

    $$\textit{C_Nc} = \frac{Nc}{NcDes}$$

    The map for the corrected speed is then determined by:

    $$NcMap = \frac{Nc}{\textit{C_Nc}}$$

    The pressure ratio map is determined by using the following equation:

    $$PRmapRead = \frac{PR_{In} - 1}{\textit{C_PR}}+1$$

    in which <i>C_PR</i> is determined by the following equation, if iDesign
    is enabled, or by the user-specified value.

    $$\textit{C_PR} = \frac{PR_{In} - 1}{PRmapDes - 1}$$

    The output total pressure is calculated by using the following equation:

    $$Pt_{Out} = \frac{Pt_{In}}{PR_{In}}$$

   The total flow input is determined by using the turbine maps and depends
   on the setting of iDesign. If iDesign is enabled, the flow scalar constant
   is determined by the following equation. Otherwise, this constant is determined
   by the value that the user inputs in the T-Map tab.

   $$\textit{C_Wc} = \frac{W_{In}*\sqrt{\Theta}}{\delta*WcMap}$$

   In the above equation, <i>WcMap</i> is determined by interpolating the turbine
   map vectors. The total, calculated flow input is determined by the following
   equation:

   $$WcCalc_{In} = WcMap * \textit{C_Wc}$$

   The total corrected flow input at the inlet and at station one is
   determined by:

   $$ Wc_{In} = \frac{W_{In} * \sqrt{\Theta}}{\delta}$$
   $$ Wc_{s1-In} = \frac{W_{s1-In}*\sqrt{\Theta}}{\delta}$$

   The turbine's efficiency is determined by the following process. First, the
   efficiency map is determined by interpolating the input map vectors. Then
   the efficiency scalar constant is determined by the following equation, if
   iDesign is enabled. Otherwise, this constant is determined by the user-specified
   value.

   $$\textit{C_Eff} = \frac{EffDes}{EffMap}$$

   The efficiency of the turbine is then determined by:

   $$Eff = EffMap * \textit{C_Eff}$$

   The ideal output conditions are determined using the assumption that the
   output entropy is equal to the input entropy (perfectly isentropic). The
   ideal total temperature is determined via table lookup using the entropy
   as the lookup parameter. The ideal total enthalpy is then determined via
   table lookup using the ideal total temperature as the lookup parameter.
</p>
<h2>
Energy Output
</h2>
<p>
    The actual output enthalpy and temperature are determined using the
    following process. First, the actual total enthalpy output is determined
    by the following equation:

    $$ht_{Out} = \frac{[(htIdeal_{Out} - ht_{s1-In})*Eff + ht_{s1-In}]*W_{s1-In}+dHcool_{Out}}{W_{Out}}$$

    The output total temperature is then determined using via table lookup
    using the calculated value of the output total enthalpy and output fuel
    to air ratio as the lookup parameters.

<p>
    The output power is determined by the following equation, in which
    <i>C_BTU_PER_SECtoHP</i> is a unit conversion factor. It is important
    to note that this only takes into account cooling flow that enters at the
    front of engine (station one) and does not account for cooling flows at
    other positions.

    $$Pwr_{Out} = (ht_{s1-In} - htIdeal_{Out})*Eff*W_{s1-In} * \textit{C_BTU_PER_SECtoHP}$$

    The output torque to the shaft is determined using the calculated value
    of the output power and the following equation:

    $$Torque_{Out} = \frac{\textit{C_HP_PER_RPMtoFT_LBF}*Pwr_{Out}}{Nmech}$$
<h2>
Normalized Error
</h2>
    If iDesign is enabled, the normalized error is based on speed and is determined by the following equation:

    $$NError_{Out} = \frac{Nmech - NDes}{NDes}$$

    If iDesign is not enabled, the normalized error is based on flow and is determined by
    the following equation:

    $$NError_{Out} = \frac{Wc_{s1-In}-WcCalc_{In}}{Wc_{s1-In}}$$

    If <i>W<sub>s1-In</sub></i> is set to zero, the normalized error will
    be equal to 100. This will also occur if iDesign is enabled and <i>NDes</i>
    is set to zero.
</p>

<br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="instructions">
        Instructions
</div>

<p>
    To use this block:
    <ul>
        <li> Connect the input gas path flow, cooling flow, pressure ratio,
        and Nmech values to the corresponding places on the block.
        <li> Connect the outputs to the next block(s) in your simulation.
        <li> Double click the block and...
        <ol>
            <li>Select which options you will use under each tab:
            <ul style="list-style-type:circle">
                <li>Under the T-Map tab:
                <ul>
                    <li>In the bottom-right corner of the page, select which
                    (if any) scalars you will use for the plot. <br> Options include:
                    <ol>
                        <li>None: Plots the maps as defined.
                        <li>User Defined: Plots the maps with Wc, PR, and Eff
                        scaled using the scalars defined in the T-Map tab.
                        <li>iDesign: Plots the maps with Wc, PR, and Eff scaled
                        using the scalars calculated with iDesign, as defined
                        in the iDesign tab.
                    </ol>
                </ul>
                <li>Under the Cooling Flow tab:
                <ul>
                    <li>Check the box to enable Cooling Flow.
                </ul>
                <li>Under the iDesign tab:
                <ul>
                    <li>Select the value of iDesign_M. <br>Options include:
                    <ul style="list-style-type:disc">
                        <li> 0: iDes will be enabled and the turbine map
                        scalars will be based on design variables specified
                        by the user in the iDesign tab.
                        <li> 1: Turbine map scalars will be determined
                        from a specified file (<i>FVar_M</i>) that is uploaded by
                        the user and specified in the iDesign tab.
                        <li> 2: Turbine map scalars will be determined
                        by the scalars specified in the T-Map tab; no values
                        from the iDesign tab will be used.
                    </ul>
                </ul>
            </ul>
            <li>Input the corresponding values for the parameters you have chosen
            to use.
        </ol>
    </ul>
</p>

<br><hr><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="inputs">
        Turbine Inputs
</div>

<table>
    <tr><th> Input </th><th>Description</th></tr>
   <tr><td>CoolingFlwCharIn</td><td>Cooling flow Gas Characteristics Input,
                     5x1 bus/vector (for each cooling flow) consisting of:
            <br>- W - Gas path flow [pps]
            <br>- ht - Enthalpy [BTU/lbm]
            <br>- Tt - Total Temperature [degR]
            <br>- Pt - Total Pressure [psia]
            <br>- FAR - Combusted Fuel to Air Ratio [frac]
            <br> This feature must be enabled, see Cooling Flow tab variable (CFlwEn_M) definition</td></tr>
    <tr><td>GasPthCharIn</td><td>Gas Path Characteristics Input, 5x1 bus/vector consisting of:
            <br>- W - Gas path flow [pps]
            <br>- ht - Enthalpy [BTU/lbm]
            <br>- Tt - Total Temperature [degR]
            <br>- Pt - Total Pressure [psia]
            <br>- FAR - Combusted Fuel to Air Ratio [frac]</td></tr>
    <tr><td>PRmapIn</td><td>Map turbine Pressure Ratio, position on turbine map.
            <br> Determines Pressure ratio, efficiency, and gas path flow.
            <br> The value for this variable will need to be solved for by driving
            	 the flow error accross the engine to zero.</td></tr>
    <tr><td>Nmech</td><td>Shaft speed [rpm]</td></tr>
</table>

<br><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="outputs">
        Turbine Outputs
</div>

<table>
    <tr><th> Output </th><th> Description </th></tr>
    <tr><td>GasPthCharOut</td><td>Gas Path Characteristics Output, 5x1 bus/vector consisting of:
            <br>- W - Gas path flow [pps]
            <br>- ht - Enthalpy [BTU/lbm]
            <br>- Tt - Total Temperature [degR]
            <br>- Pt - Total Pressure [psia]
            <br>- FAR - Combusted Fuel to Air Ratio [frac]</td></tr>
    <tr><td>NErr</td><td>Normalized Error [frac], in a typical system this will
                    be driven to zero by an iterative solver</td></tr>
    <tr><td>TrqOut</td><td>Turbine Torque Output (lbf*ft), positive value for a turbine.</td></tr>
    <tr><td>T_Data</td><td>Turbine internal calculation Data, 13x1 bus/vector including:
            <br>- s_T_Nc - Corrected shaft speed map scalar value
            <br>- s_T_Wc - Corrected mass flow map scalar value
            <br>- s_T_PR - Pressure ratio map scalar value
            <br>- s_T_Eff - Efficiency map scalar value
            <br>- Wcin - Corrected mass flow input [pps]
            <br>- Wcs1in - Corrected mass flow after station 1 (contains input bleed air) [pps]
            <br>- Nc - Corrected shaft speed [rpm]
            <br>- NcMap - Corrected shaft speed from the turbine map
            <br>- WcMap - Corrected mass flow from the turbine map
            <br>- PRMap - Pressure ratio from the turbine map
            <br>- EffMap - Efficiency from the turbine map
            <br>- Pwrout - Output power [hp]
            <br>- Test - Turbine interal calculation Data
            <br>- Nmech - Mechanical shaft speed, from input [rpm]
            <br>- BlkNm - Block name as double, if required use char(BlkNm) to retrieve </td></tr>
</table>

<br><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="maskvars">
        Turbine Mask Variables
</div>

<table>
    <tr><th> Mask Variable </th><th> Description </th></tr>
    <tr><td>X_T_Map_PRVec_M</td><td>Turbine Map Pressure Ratio Vector (X-axis)(nx1)</td></tr>
    <tr><td>Y_T_Map_NcVec_M</td><td>Turbine Map Corrected Speed Vector (Y-axis)(mx1)</td></tr>
    <tr><td>T_T_Map_WcArray_M</td><td>Turbine Map Flow Array (Wc=f(Nc,PR))(mxn)</td></tr>
    <tr><td>T_T_Map_EffArray_M</td><td>Turbine Map Efficiency Array (Eff = f(Nc,PR))(mxn)</td></tr>
    <tr><td>s_T_Nc_M</td><td>Corrected Speed Scalar Constant (T_Nc)</td></tr>
    <tr><td>s_T_PR_M</td><td>Pressure Ratio Scalar Constant (T_PR)</td></tr>
    <tr><td>s_T_Wc_M</td><td>Flow Scalar Constant (T_Wc)</td></tr>
    <tr><td>s_T_Eff_M</td><td>Efficiency Scalar Constant (T_Eff)</td></tr>
    <tr><td>Plot Map</td><td>Plots the block defined map
            <br>
            <br> - Scalars: None - plots maps as defined
            <br>
            <br> - Scalars: User defined - plots maps with Wc, PR, and Eff scaled using the scalars defined in the T-map tab
            <br>
            <br> - Scalars: iDesign - plots maps with Wc, PR, and Eff scaled using scalars calculated with iDesign and located within the file defined in the iDesign tab</td></tr>
    <tr><td>CFlwEn_M</td><td>Cooling Flow Enable [check - enabled]</td></tr>
    <tr><td>T_CoolFlwPos_M</td><td>Cooling Flow position [0 at inlet,  1 at exit](cx1)
            <br> With Cooling Flow Enabled, the turbine will expect cooling flow input
                 vector length of Cx5. See CoolingFlwCharIn definition </td></tr>
    <tr><td>iDesign_M</td><td> Design fork (0, 1, 2)
            <br>
            <br>0 - iDes Enabled, Calculate turbine map scalars based on design variables
            <br>    When iDesign is set to 0, scalar constants from the Map tab will not be used.
            	    Scalars calculated will be saved in the specified file (FVar_M).
            <br>
            <br>1 - Scalar variables will be overwritten (mask Initialization) with
            	    values from a specified file (FVar_M).
            <br>    When iDesign is set to 1, scalar constants from the Map tab and the Design values
            	    from the iDesign tab will not be used.
            <br>
            <br>2 - Scalar variables from the map tab will be used as the map scalars.
            <br>    When iDesign is set to 2, scalar constants from the Map tab will be used; Design values
            	    and file definitions from the iDesign tab will not be used. </td></tr>
    <tr><td>NcDes_M</td><td>Map Design Corrected Shaft Speed [rpm], design point corrected speed used in map</td></tr>
    <tr><td>EffDes_M</td><td>Design Efficiency [frac], actual design point tubine efficiency </td></tr>
    <tr><td>PRDes_M</td><td>Map Design Pressure Ratio [frac], design point PR used in map</td></tr>
    <tr><td>NDes_M</td><td>Design Shaft Speed [rpm], actual design point speed</td></tr>
    <tr><td>FVar_M</td><td>File name for iDes Variables</td></tr>
</table>
<br>
Note: Vectors are the x and/or y axis to a table made of an array.
Scalars are used to "scale" the turbine map for off design turbines.


<br><hr><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class = "errors">
    Potential Errors
</div>
<p>
When using this block, you may receive one of the following errors/warnings. The table
below lists the errors/warnings that you may see and the reason why it is being displayed.
</p>
<table>
    <tr><th> Error/Warning </th><th>Description</th></tr>
    <tr><td>One or more of the cooling flow input vector elements is missing.</td><td>
                    Error appears if the input vector is not the correct size.
                    Recall each flow needs to be a 5x1 vector consisting of W, ht, Tt, Pt, FAR.</td></tr>
    <tr><td>Number of cooling flow inputs does not match the length of the cooling flow
                position vector defined in the mask.</td><td>Error appears if the
                cooling flow input vector is not the correct size (5x1).</td></tr>
    <tr><td>Cooling flow position element needs to be defined as a 0 or 1.</td><td>
                    Error appears if any of the elements of T_BldPos are not 0 or 1.</td></tr>
    <tr><td>Error calculating WcMap.</td><td>Error appears if the table size
                    does not match the axis vector lengths. One or more vectors
                    is not the correct size.</td></tr>
    <tr><td>Error calculating EffMap.</td><td>Error appears if the table size
                    does not match the axis vector lengths. One or more vectors
                    is not the correct size.</td></tr>
</table>

<br><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
</body>